package com.fangyi.yunmusic.service.utils;


import com.fangyi.yunmusic.config.ResourceConfig;
import com.fangyi.yunmusic.mapper.UserMapper;
import com.fangyi.yunmusic.pojo.User;
import com.fangyi.yunmusic.pojo.vo.UserVO;
import com.fangyi.yunmusic.utils.FileServerUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class VOConvertUtils {
    @Autowired
    private  ResourceConfig resourceConfig;
    public  UserVO convertToUserVO(User user){
        UserVO userVO = new UserVO();
        BeanUtils.copyProperties(user, userVO);
        userVO.setAvatarImgUrl(FileServerUtils.getUserAvatarUrl(resourceConfig.getFileServer(), user.getAvatarImgId()));
        return userVO;
    }
}
